<%@page import="com.entity.UserInfo"%>
<%@page import="com.biz.UserBizImpl"%>
<%@page import="com.biz.IUserBiz"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("utf-8");
	String account=request.getParameter("account");
	String pwd=request.getParameter("pwd");
	IUserBiz ubiz=new UserBizImpl();
	UserInfo user=new UserBizImpl().login(account, pwd);
	if(user==null){
%>
	<script>alert("账号或密码有误，登录失败");location="/myweb2/login.jsp";</script>
<%
	}else{
		//设置session的值
		session.setAttribute("loger", user);
		//设置cookie的值
		Cookie c =new Cookie("logername",user.getUname());
		c.setPath("/");
		c.setMaxAge(3*24*60*60);
		response.addCookie(c);
		
		if(user.getIsadmin()==0){
		%>
			<script>location="../index.jsp";</script>
		<%
		}else{
		%>
			<script>location="../admin/index.jsp";</script>
		<%
		}
	}
%>

